Skip to content

Fix translation of string message content#5

Open
tristanmanchester wants to merge 1 commit intoopenai:mainfrom
tristanmanchester:fix-string-content-translation
Open

Fix translation of string message content#5
tristanmanchester wants to merge 1 commit intoopenai:mainfrom
tristanmanchester:fix-string-content-translation

Conversation

@tristanmanchester
Copy link
Copy Markdown

Summary

  • Normalize plain string message content into { text: ... } before it enters the translation pipeline.
  • Replace the corresponding entry in translatedMessages with the normalized translatable message so async translation responses update the translated clone.
  • Remove the previous @ts-ignore by constructing the TranslatableMessage through explicit text/developer branches.

Bug

Message.content can be either an array of content objects or a plain string. The translation queue previously used message.content[0] for every text/developer message. For plain strings, that indexes the first character, so "Hello" became "H" instead of a text content object.

That malformed shape meant translation requests were built from the wrong content and downstream logic expected object fields such as text on a string character.

Fix

The translation queue now calls the existing getContentFromContentOrString helper, which converts string content into { text: fullString } and preserves array-backed content by selecting the first content object. The normalized message is assigned back into translatedMessages[i] before translation starts, ensuring response handling mutates the translated clone rather than a temporary object.

Verification

  • Confirmed the problematic message.content[0] expression is no longer used in the translation queue.
  • Ran pnpm run build successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant